import Mock from "mockjs"



//登录接口
Mock.mock('localhost:8080/login', 'post', (req) => {
    console.log(req)
    const { username, password } = JSON.parse(req.body)
    if (username === "user" && password === "123456") {
        return {
            code: 200,
            success: true,
            message: "登录成功",
            token: "s1d23asd4as5d6a1sd",
            nickname: "刘世杰"
        }
    } else {
        return {
            code: 100,
            success: false,
            message: "帐号或密码有误",
        }
    }
})
//账户修改接口
Mock.mock('localhost:8080/fix', 'post', (req) => {
    console.log(req)
    const { password, newPassword, rePassword } = JSON.parse(req.body)
    if (password === newPassword) {
        return {
            code: 100,
            success: false,
            message: "新密码与旧密码不得相同",
        }
    }
    if (password == "123456") {
        //设置新密码
        // 退出重新登录
        return {
            code: 200,
            success: true,
            message: "修改成功,重新登录",
        }
    }
})
//记录入职时间
Mock.mock('localhost:8080/in', 'get', () => {
    return {
        code: 200,
        success: true,
        message: "操作成功",
        time: "2020-07-01 00:00:00"
    }
})
// 班级管理接口
Mock.mock('localhost:8080/grade', 'get', () => {
    return {
        code: 200,
        success: true,
        message: "成功",
        data: Mock.mock({
            'users|20-50': [{
                "index|+1": 1,
                "department|+1": ["计算机科学与工程学院", "文学院", "财经学院", "美术学院", "电信学院", "土木学院", "数学与统计学院"],
                "grade|+1": ["计算机科学与工程学院", "文学院", "财经学院", "美术学院", "电信学院", "土木学院", "数学与统计学院"],
                "name": "@cname",
                "total": 50,
                "tel|11": 1,
            }]
        })
    }
})
// export default Mock